#!/usr/bin/env node

const Koa = require('koa'),
      Router = require('koa-router');

const app = new Koa(),
      router = new Router();

router.prefix ('/api/authors');

//curl http://localhost:3000/api/authors/\?page\=22\&limit\=10 
router.get('/',async (ctx)=>{
  ctx.body = '分页查询漫画书作者';
});


//curl http://localhost:3000/api/authors/wangding/\?page\=22\&limit\=10 
router.get('/:authorName',async (ctx)=>{
  ctx.body = '按名称查询漫画书作者';
})


//curl -d 'abc' http://localhost:3000/api/authors/\?page\=22\&limit\=10
router.post('/',async (ctx)=>{
 ctx.body = '按名称添加漫画书作者';
})

//curl -X PUT -d 'abc' http://localhost:3000/api/authors/22
router.put('/:id',async (ctx)=>{
 ctx.body = '修改漫画书作者';
})

//curl -X DELETE http://localhost:3000/api/authors/216
router.delete('/:id',async (ctx)=>{
 ctx.body = '删除漫画书作者';

})

app.use(router.routes());
app.listen(3000);
